bugfix(contain): Restore retail compatibility after crash fix in OpenContain::killAllContained#2439
Conversation
|
| Filename | Overview |
|---|---|
| GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp | Rewrites killAllContained() to keep m_containList live during iteration instead of pre-draining it, fixing garrisoned-building team ownership and GLA Demolition damage behavior while still safely handling recursive kill() callbacks by resetting the iterator to begin() after each kill. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["killAllContained() entry"] --> B["it = m_containList.begin()"]
B --> C{"it != end?"}
C -- No --> H["DEBUG_ASSERTCRASH list empty"]
H --> I["clear() / size=0 safety net"]
I --> Z["return"]
C -- Yes --> D["rider = *it"]
D --> E{"rider != null?"}
E -- No --> F["++it"] --> C
E -- Yes --> G["erase(it), --m_containListSize"]
G --> J["onRemoving(rider)"]
J --> K["rider->onRemovedFrom(container)"]
K --> L["rider->kill()"]
L --> M{"kill() recursively\ndrained the list?"}
M -- Yes --> N["it = begin() == end()"]
M -- No --> O["it = begin()\nnext element"]
N --> C
O --> C
Reviews (4): Last reviewed commit: "Tweaked comments." | Re-trigger Greptile
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp
Outdated
Show resolved
Hide resolved
…OpenContain::killAllContained.
04af4f6 to
341c271
Compare
|
Does this still prevent the crashing with tech terrors? |
Yes, the original crash is still fixed. I made sure of that, and also created a reproduction of it in the crash fix PR. |
xezon
left a comment
There was a problem hiding this comment.
Logic looks plausible. Comments need polishing.
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp
Outdated
Show resolved
Hide resolved
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp
Outdated
Show resolved
Hide resolved
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp
Outdated
Show resolved
Hide resolved
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp
Outdated
Show resolved
Hide resolved
|
Updated the comments. I got rid of the old 'Neutron Shells + GLA Technical containing GLA Terrorists' issue reproduction description that seems too detailed to me. |
The way the crash fix was implemented in #921 assumes that the logic behavior doesn't change if
m_containList/m_containListSizeis already empty with the first iteration. This is not the case in the attached replay in #2215.If
m_containList/m_containListSizeis empty, it'll make garrisoned civilian buildings unoccupied on the first iteration instead of the last iteration, and the GLA Demolition upgrade would cause damage to the building for each occupant instead of just the last one when hit with a neutron shell.garrisoned_gla_demolition_upgrade_neutron_shell_incorrect.mp4
garrisoned_gla_demolition_upgrade_neutron_shell_correct.mp4
Pay attention to the health of the civilian building. In the correct version, only the detonation of the last GLA RPG Trooper causes damage instead of every one.
TODO: